using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;

using Tool;

using Xunit;

namespace TestProject1
{
    public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
            var list = new List<Abc>();
            list.Add(new Abc() { Key = "A", Value = "С��" });
            list.Add(new Abc() { Key = "B", Value = "����" });
            list.Add(new Abc() { Key = "C", Value = "���" });

            var abcdto = new AbcDto();
            foreach (var item in list)
            {
                //var p = GetType().GetField(systemsettingdto).GetValue(this);
                //p.GetType().GetProperty("Name").SetValue(p, "new name", null);

                abcdto.PropertySetValue(item.Key, item.Value);

            }
        }
        [Fact]
        public void Test2()
        {
            var abcdto = new AbcDto();
            abcdto.A = "123654";
            abcdto.B = "55165";

            var a = abcdto.GetPropertyElements<AbcDto>();


            Type info = typeof(AbcDto);

            PropertyInfo[] ps = info.GetProperties();

            var pss = info.GetProperties();
            foreach (var p in pss)
            {
                var pattrs = p.GetCustomAttributes(false);
                for (int i = 0; i < pattrs.Length; i++)
                {
                    var aaa = pattrs[i];

                    //AttributeInfo t = pattrs[i] as AttributeInfo;
                    //if (t != null)
                    //{
                    //    Console.WriteLine("��������" + p.Name);
                    //    System.Console.WriteLine(t.Name + "  " + t.Type + "    " + t.message);
                    //}

                }
            }
        }

    }


    public class Abc
    {
        public string Key { get; set; }

        public string Value { get; set; }
    }

    public class AbcDto
    {
        /// <summary>
        /// ��Һ�
        /// </summary>
        [Description("��Һ�")]
        public string A { get; set; }
        /// <summary>
        /// ���Ǻ�
        /// </summary>
        [Description("���Ǻ�")]
        public string B { get; set; }
    }
}
